<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="../../resources/templates/login.xhtml"
                xmlns:p="http://primefaces.org/ui"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:sec="http://www.springframework.org/security/facelets/tags" >

    <ui:define name="menu_horizontal">
        <sec:ifAnyGranted roles="ROLE_ALUNO,ROLE_ADMINISTRADOR">
            <ui:include src="/site/acessoAluno/menu.xhtml" />
        </sec:ifAnyGranted>
    </ui:define>
    
    <ui:define name="corpo">
        
        <sec:ifAnyGranted roles="ROLE_ALUNO,ROLE_ADMINISTRADOR">
            <h:form id="formSalvar" enctype="multipart/form-data">
                
                <p:panel> 
                    <p:messages id="msgs"/> 
                    <h:panelGrid >

                    Certificado Digitlizado:
                        <p:fileUpload fileUploadListener="#{controllerEntradaAtividade.handleFileUpload}" mode="advanced" sizeLimit="300000" allowTypes="/(\.|\/)(pdf)$/"
                                    multiple="false" style="width: 600px;" invalidFileMessage="Apenas PDF" invalidSizeMessage="Tamanho máximo 300kb"
                                    required="true" requiredMessage="É obrigatório anexar o arquivo." showButtons="false" label="Arquivo"/> *(Arquivo formato PDF, tamanho máx. 100kb)

                        <h:panelGrid columns="3"> 
                            
                            Atividade Requerida:
                            <!-- POPULANDO COM OBJETO -->
                            <p:selectOneMenu value="#{controllerEntradaAtividade.entradaAtv.atividadecomplementar}" converter="#{AtividadeComplementarConverter}" style="width: 450px">
                                <f:selectItem itemLabel="-- Selecione --" noSelectionOption="true"/>
                                <f:selectItems value="#{controllerAtvComp.lista}" var="tipo" itemValue="#{tipo}" itemLabel="#{tipo.atividade}"/>
                            </p:selectOneMenu>
                                
                            <p:commandLink   ajax="true" process="@this" oncomplete="dialogCad.show();" update=":formCad">
                                <p:graphicImage value="/resources/images/add.png" />
                            </p:commandLink>
                                
                        </h:panelGrid>

                        
                        Observação:   <p:editor id="editor" value="#{controllerEntradaAtividade.entradaAtv.observacao}" width="600" style="right:600px;" /> 
                        

                        <p:commandButton value="Solicitar" actionListener="#{controllerEntradaAtividade.salvar()}" ajax="true" update="@form,:growl"/>

                    </h:panelGrid>
                </p:panel>

                <p:dataTable id="tabela" var="p" value="#{controllerEntradaAtividade.listaDM}" emptyMessage="Nada encontrado...">
                   
                     <p:column headerText="Cod">
                        <h:outputText value="#{p.id}"/>
                    </p:column>
                    <p:column headerText="Solicitante">
                        <h:outputText value="#{p.aluno.nome}"/>
                    </p:column>
                    <p:column headerText="Área">
                        <h:outputText value="#{p.atividadecomplementar.atividadecomplementartipo.tipo_atividade}"/>
                    </p:column>
                    <p:column headerText="Atividade">
                        <h:outputText value="#{p.atividadecomplementar.atividade}"/>
                    </p:column>
                   
                    <p:column headerText="Data">
                        <h:outputText value="#{p.data_entrada}">
                            <f:convertDateTime pattern="dd/MM/yyyy"/>
                        </h:outputText>
                    </p:column>
                     <p:column>
                        <h:outputText  value="#{p.aprovado}"/>
                    </p:column>
                    <p:column>
                            <p:commandButton value="Download" ajax="false" onclick="PrimeFaces.monitorDownload(start, stop)" icon="ui-icon-arrowthichk-s">  
                            <p:fileDownload value="#{controllerEntradaAtividade.fileDownloadAction()}"/>
                        </p:commandButton>
                    </p:column>
                    <p:column>
                        <p:commandLink value="apagar" actionListener="#{controllerEntradaAtividade.remover()}" process="@this" ajax="true" update="@form"/>
                    </p:column>
                </p:dataTable>

                <p:dialog modal="true" widgetVar="statusDialog" draggable="false" closable="false" resizable="false">  
                    <p:graphicImage value="/resources/images/ajax-bar.gif" />
                </p:dialog>
                
                
             
                
            </h:form>
            
            
             <p:dialog widgetVar="dialogCad" resizable="false" closable="false" modal="true" showEffect="slide" hideEffect="slide">
                <h:form id="formCad">
                    <p:panel style="width: 320px;">
                        <p:messages id="msgs"/> 
                        <h:panelGrid columns="2">
                                
                      
                        Tipo da atividade:*
                        <!-- POPULANDO COM OBJETO -->
                        <p:selectOneMenu value="#{controllerAtvComp.atvComp.atividadecomplementartipo}" converter="#{AtividadeComplementarTipoConverter}"  style="width: 160px">
                            
                        <f:selectItems value="#{controllerAtvCompTipo.lista}" var="tipo" itemValue="#{tipo}" itemLabel="#{tipo.tipo_atividade}"/>
                        </p:selectOneMenu>

                        Nome da atividade:* <p:inputText value="#{controllerAtvComp.atvComp.atividade}"  />

                        Carga Horária:* <p:inputText value="#{controllerAtvComp.atvComp.ch_horaria}"  />
                                             
 
                        <p:commandButton value="Salvar" actionListener="#{controllerAtvComp.salvar()}" oncomplete="dialogCad.hide()" update=":formSalvar" 
                                                style="margin-top: 30px"/>
                        <p:commandButton value="Cancelar" actionListener="#{controllerAtvComp.limpar()}" oncomplete="dialogCad.hide()" update=":formSalvar" 
                                                style="margin-top: 30px;margin-left: 0px;"/>
                        </h:panelGrid>
                    </p:panel>
                </h:form>
            </p:dialog>
            
        </sec:ifAnyGranted>
        
    </ui:define>
    
</ui:composition>
